
module libeventd.ratelim.Internal ;

import libeventd.Types;


extern(C):

struct ev_token_bucket {
	ev_int32	read_limit, write_limit;
	ev_uint32	last_updated;
}

struct ev_token_bucket_cfg {
	ev_uint32	read_rate;
	ev_uint32	read_maximum;
	ev_uint32	write_rate;
	ev_uint32	write_maximum;
	timeval	tick_timeout;
	ev_uint	msec_per_tick;
}


ev_int ev_token_bucket_update(ev_token_bucket *bucket, ev_token_bucket_cfg *cfg,  ev_uint32_t current_tick);
ev_uint32_t ev_token_bucket_get_tick(timeval *tv,ev_token_bucket_cfg *cfg);
ev_int ev_token_bucket_init(ev_token_bucket *bucket,ev_token_bucket_cfg *cfg,   ev_uint32_t current_tick,ev_int reinitialize);
